@model ZKEACMS.FormGenerator.Models.FormField
@{
    Style.Reqiured("captcha").AtHead();
    Script.Reqiured("captcha").AtFoot();

    string maxLength = "10";
    Model.Attributes.TryAdd("data-val-length", L("The max length of {0} is {1}").Text.FormatWith(Model.DisplayName, maxLength));
    Model.Attributes.TryAdd("data-val-length-max", maxLength);
    Model.Attributes.TryAdd("data-captcha", Url.Action("Image", "Captcha"));
    Model.Attributes["class"] = "required form-control image-captcha";
}
<div class="form-group size-@Model.Size">
    @if (Model.DisplayName.IsNotNullAndWhiteSpace())
    {
        <label class="control-label" for="@Model.ID">
            @Model.DisplayName
            @if (Model.IsRequired)
            {
                <span class="required">*</span>
            }
        </label>
    }
    @if (Model.Description.IsNotNullAndWhiteSpace())
    {
        <span class="text-muted">
            <span>@Model.Description</span>
        </span>
    }

    <table class="captcha-container">
        <tbody>
            <tr>
                <td>
                    @Html.TextBox(Model.ID, Model.Value, Model.Attributes)
                </td>
                <td>
                    <a class="image-captcha" href="javascript:void(0)" data-captcha="@Url.Action("Image", "Captcha")">
                        <img src="@Url.Action("Image", "Captcha")" />
                    </a>
                </td>
            </tr>
        </tbody>
    </table>

    @Html.ValidationMessage(Model.ID)
</div>